<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-course-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">课程名：</label>
				<div class="col-sm-8">
					<input id="courseName" name="courseName" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">任课老师：</label>
				<div class="col-sm-8">
					<select id="teacher" class="form-control select2-hidden-accessible" multiple="">
						<option th:each="teacher:${teachers}" th:value="${teacher.userId}" th:text="${teacher.userName}"  th:disabled="${teacher.status == '1'}"></option>
					</select>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">开课班级：</label>
				<div class="col-sm-8">
					<select id="class" class="form-control select2-hidden-accessible" multiple="">
						<option th:each="class:${classes}" th:value="${class.deptId}" th:text="${class.deptName}" th:disabled="${class.status == '1'}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">课程状态：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" th:checked="true" class="onoffswitch-checkbox" id="status">
						<label class="onoffswitch-label" for="status">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>


    <script type="text/javascript">
		var prefix = ctx + "system/course"

		$("#form-course-add").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});


		function submitHandler() {
			if ($.validate.form()) {
				var data=$("#form-course-add").serializeArray();
				var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
				var teacherId=$.form.selectSelects("teacher");
				var classId=$.form.selectSelects("class");
				data.push({"name": "status", "value": status});
				data.push({"name": "teacherIds", "value": teacherId});
				data.push({"name": "classIds", "value": classId});
				$.operate.save(prefix + "/add",data);
			}
		}

	</script>
</body>
</html>
